package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author Tsuchi
 * @description TODO
 * @date 2024/12/21 11:34
 */
// minio配置装配类
@Configuration

@EnableConfigurationProperties(MinioProperties.class)
public class MinioConfiguration {
	@Autowired
	private MinioProperties minioProperties;
	@Bean
	public MinioClient minioClient(){
		return MinioClient.builder()
			// 配置服务器地址
			.endpoint(minioProperties.getEndpoint())
			// 创建与服务器的会话连接 传入账号密码
			.credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
			.build();
	}
}
